package com.leetcode.LC_MED;

public class LC11 {
    public int maxArea(int[] height) {

        int a = 0, b = height.length - 1;
        int rs = 0;
        while (a < b) {
            rs = Math.max(rs, (b - a) * Math.min(height[a], height[b]));
            if (height[a] < height[b]) {
                a++;
            } else {
                b--;
            }
        }
        return rs;
    }

    public static void main(String[] args) {
        System.out.println(new LC11().maxArea(new int[]{1, 8, 6, 2, 5, 4, 8, 3, 7}));
    }
}
